{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## numpy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'numpy.ndarray'>\n",
      "<class 'numpy.ndarray'>\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([[ 2.99219999],\n",
       "       [ 0.96274391],\n",
       "       [-2.56189779],\n",
       "       [ 1.97409698],\n",
       "       [-0.15078346],\n",
       "       [ 2.32990259],\n",
       "       [ 2.55509555],\n",
       "       [ 0.06608453],\n",
       "       [ 2.00566231],\n",
       "       [-2.15638143]])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "m = 10\n",
    "X = 6 * np.random.rand(m, 1) - 3 \n",
    "y = 0.5 * X**2 + X + 2 + np.random.randn(m, 1)\n",
    "print(type(X))\n",
    "print(type(y))\n",
    "X"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>index</th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "      <th>user_no</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>0.408835</td>\n",
       "      <td>Christopher</td>\n",
       "      <td>4</td>\n",
       "      <td>user_0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>0.808485</td>\n",
       "      <td>Christopher</td>\n",
       "      <td>4</td>\n",
       "      <td>user_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>0.212988</td>\n",
       "      <td>Christopher</td>\n",
       "      <td>4</td>\n",
       "      <td>user_2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>0.667811</td>\n",
       "      <td>Christopher</td>\n",
       "      <td>4</td>\n",
       "      <td>user_3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>0.967158</td>\n",
       "      <td>pooh</td>\n",
       "      <td>4</td>\n",
       "      <td>user_4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>5</td>\n",
       "      <td>0.843433</td>\n",
       "      <td>pooh</td>\n",
       "      <td>4</td>\n",
       "      <td>user_5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>6</td>\n",
       "      <td>0.566432</td>\n",
       "      <td>rabbit</td>\n",
       "      <td>4</td>\n",
       "      <td>user_6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>7</td>\n",
       "      <td>0.648475</td>\n",
       "      <td>pooh</td>\n",
       "      <td>4</td>\n",
       "      <td>user_7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>8</td>\n",
       "      <td>0.326103</td>\n",
       "      <td>Christopher</td>\n",
       "      <td>4</td>\n",
       "      <td>user_8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>9</td>\n",
       "      <td>0.829099</td>\n",
       "      <td>piglet</td>\n",
       "      <td>4</td>\n",
       "      <td>user_9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   index         a            b  c user_no\n",
       "0      0  0.408835  Christopher  4  user_0\n",
       "1      1  0.808485  Christopher  4  user_1\n",
       "2      2  0.212988  Christopher  4  user_2\n",
       "3      3  0.667811  Christopher  4  user_3\n",
       "4      4  0.967158         pooh  4  user_4\n",
       "5      5  0.843433         pooh  4  user_5\n",
       "6      6  0.566432       rabbit  4  user_6\n",
       "7      7  0.648475         pooh  4  user_7\n",
       "8      8  0.326103  Christopher  4  user_8\n",
       "9      9  0.829099       piglet  4  user_9"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# from itertools import enumerate\n",
    "def cons__(c):\n",
    "    def x(m):\n",
    "        return pd.Series(c, index=range(0, m))\n",
    "    return x\n",
    "\n",
    "def rand_(m):\n",
    "    return pd.Series(np.random.rand(m))\n",
    "\n",
    "def range_(m):\n",
    "    return pd.Series(range(0, m))\n",
    "\n",
    "# np.random.choice(aa_milne_arr, 5, p=[0.5, 0.1, 0.1, 0.3])\n",
    "def choice__(c: list):\n",
    "    def x(m):\n",
    "        return pd.Series(np.random.choice(c, m))\n",
    "    return x\n",
    "\n",
    "m=10\n",
    "columns = {\n",
    "    \"index\": range_,\n",
    "    \"a\": rand_,\n",
    "    \"b\": choice__(['pooh', 'rabbit', 'piglet', 'Christopher']),\n",
    "    \"c\": cons__(4),\n",
    "    \"d\": choice__([True, False]),\n",
    "}\n",
    "data = {key: value(m) for key, value in columns.items()}\n",
    "df = pd.DataFrame(data)\n",
    "\n",
    "df['user_no'] = df['index'].apply(lambda x: \"user_\" + str(x))\n",
    "df"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "mlflow-dev-env",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
